package com.boardgame.gwt.data.space;

import com.boardgame.gwt.data.tile.GwtSpaceTile;
import com.boardgame.gwt.data.tile.station.GwtStationTile;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 建筑格子
 */
@Data
public class GwtSpaceRailroad extends GwtSpace{

    /**
     * 后面是否有×
     */
    private boolean isAfterCha;

    /**
     * 分数
     */
    private int vpoints;

    public GwtSpaceRailroad(){
        this.setSize(1);
        this.setBordercolor("black");
    }

    /**
     * 创建铁路格子
     * @return
     */
    public static List<GwtSpace> createSpaceRailroad(){
        List<GwtSpace> list = new ArrayList<>();
        //有叉叉的地方
        Integer[] list_cha={3,4,5,7,9,10,11,13,15,16,17};
        List<Integer> list1 = Arrays.asList(list_cha);
        //tile
        Integer[] list_tile = {4,7,10,13,16};
        List<Integer> list2 = Arrays.asList(list_tile);
        List<GwtSpaceTile> listTile = GwtStationTile.createStationTile();

        //分数
        Integer[][] list_point = {{
                4, 7, 10, 13, 16, 21, 25, 29, 33, 39
        }, {
                2, 2, 4, 4, 6, 8, 7, 6, 5, 3
        }
                , {
                1, 2, 3, 4, 5, 6, 7, 8, 8, 9
        }
        };
        List<Integer> list3 = Arrays.asList(list_point[0]);
        int index_point = 0;
        for (int i =1 ;i<39+1;i++){
            GwtSpaceRailroad gwtSpaceRailroad = new GwtSpaceRailroad();
            gwtSpaceRailroad.setColumn(i);
            //x
            if (list1.contains(i)){
                gwtSpaceRailroad.setAfterCha(true);
            }
            //tile
            if (list2.contains(i)){
                gwtSpaceRailroad.setGwtSpaceTile(listTile.remove(0));
            }
            //分数
            if (list3.contains(i)){
                gwtSpaceRailroad.setCost(list_point[1][index_point]);
                gwtSpaceRailroad.setVpoints(list_point[2][index_point]);
                index_point++;
            }
            list.add(gwtSpaceRailroad);
        }

        return list;
    }
}